﻿import QtQuick 2.15
import QtQuick.Controls 2.15

/*
  底部切换按钮
*/

Item {
    id:backGround
    width: screenWidth
    height: 150

    Rectangle{
        anchors.fill: backGround
        // color: "red"
        border.width: 5
        border.color: "#F0F8FF"
    }

    property int currentPage: 1

    Row{
       Repeater{
           model:7

           Rectangle{
              width: backGround.width / 7
              height: 150
              color: index === currentPage ? "#FF4500" :"#00FA9A"
              border.width: 5
              border.color: "#F0F8FF"

              Text{
                  anchors.centerIn: parent
                  font.pixelSize: 40
                  font.bold: true
                  color: "black"
                  text: index === 0 ? qsTr("登录"+"\n"+"页面") :
                        index === 1 ? qsTr("加工"+"\n"+"页面") :
                        index === 2 ? qsTr("超长"+"\n"+"加工") :
                        index === 3 ? qsTr("超短"+"\n"+"加工") :
                        index === 4 ? qsTr("排料"+"\n"+"加工") :
                        index === 5 ? qsTr("角码"+"\n"+"加工") :
                                      qsTr("管理"+"\n"+"界面")
              }

              MouseArea{
                  anchors.fill: parent

                  onClicked: {
                      currentPage = index
                      parent.forceActiveFocus()

                      if( currentPage === 0 )
                      {
                          loginWindow.visible = true
                          processWindow.visible = false
                          ls_LocationWindow.visible = false
                          lg_ChooseWindow.visible = false
                          extraLongProcessWindow.visible = false
                          extraShortProcessWindow.visible = false
                          pl_ProcessWindow.visible = false
                          netWorkFormulaWindow.visible = false
                          qrCodeFormulaWindow.visible = false
                          jm_ProcessWindow.visible = false
                          io_MonitorWindow.visible = false
                          printerSettingWindow.visible = false                          
                          managerSettingWindow.visible = false
                          advanceSettingWindow.visible = false
                          servoParameterSetting.visible = false
                          materialRackParameter.visible = false
                          locationCompensateSetting.visible = false
                          anyLocationCompensate.visible = false
                          changePasswdWindow.visible = false
                          deviceLayoutWindow.visible = false
                      }
                      else if( currentPage === 1 )
                      {
                          loginWindow.visible = false
                          processWindow.visible = true
                          ls_LocationWindow.visible = false
                          lg_ChooseWindow.visible = false
                          extraLongProcessWindow.visible = false
                          extraShortProcessWindow.visible = false
                          pl_ProcessWindow.visible = false
                          netWorkFormulaWindow.visible = false
                          qrCodeFormulaWindow.visible = false
                          jm_ProcessWindow.visible = false
                          io_MonitorWindow.visible = false
                          printerSettingWindow.visible = false
                          managerSettingWindow.visible = false
                          advanceSettingWindow.visible = false
                          servoParameterSetting.visible = false
                          materialRackParameter.visible = false
                          locationCompensateSetting.visible = false
                          anyLocationCompensate.visible = false
                          changePasswdWindow.visible = false
                          deviceLayoutWindow.visible = false

                          // 切换工作模式 - 手动加工
                          Cpp_Connect.write_modbus_rtu_Hold("48","1")
                      }
                      else if( currentPage === 2 )
                      {
                          loginWindow.visible = false
                          processWindow.visible = false
                          ls_LocationWindow.visible = false
                          lg_ChooseWindow.visible = false
                          extraLongProcessWindow.visible = true
                          extraShortProcessWindow.visible = false
                          pl_ProcessWindow.visible = false
                          netWorkFormulaWindow.visible = false
                          qrCodeFormulaWindow.visible = false
                          jm_ProcessWindow.visible = false
                          io_MonitorWindow.visible = false
                          printerSettingWindow.visible = false
                          managerSettingWindow.visible = false
                          advanceSettingWindow.visible = false
                          servoParameterSetting.visible = false
                          materialRackParameter.visible = false
                          locationCompensateSetting.visible = false
                          anyLocationCompensate.visible = false
                          changePasswdWindow.visible = false
                          deviceLayoutWindow.visible = false

                          // 切换工作模式 - 超长加工
                          Cpp_Connect.write_modbus_rtu_Hold("48","4")
                      }
                      else if( currentPage === 3 )
                      {
                          loginWindow.visible = false
                          processWindow.visible = false
                          ls_LocationWindow.visible = false
                          lg_ChooseWindow.visible = false
                          extraLongProcessWindow.visible = false
                          extraShortProcessWindow.visible = true
                          pl_ProcessWindow.visible = false
                          netWorkFormulaWindow.visible = false
                          qrCodeFormulaWindow.visible = false
                          jm_ProcessWindow.visible = false
                          io_MonitorWindow.visible = false
                          printerSettingWindow.visible = false
                          managerSettingWindow.visible = false
                          advanceSettingWindow.visible = false
                          servoParameterSetting.visible = false
                          materialRackParameter.visible = false
                          locationCompensateSetting.visible = false
                          anyLocationCompensate.visible = false
                          changePasswdWindow.visible = false
                          deviceLayoutWindow.visible = false

                          // 切换工作模式 - 手动加工
                          Cpp_Connect.write_modbus_rtu_Hold("48","5")

                      }
                      else if( currentPage === 4 )
                      {
                          loginWindow.visible = false
                          processWindow.visible = false
                          ls_LocationWindow.visible = false
                          lg_ChooseWindow.visible = false
                          extraLongProcessWindow.visible = false
                          extraShortProcessWindow.visible = false
                          pl_ProcessWindow.visible = true
                          netWorkFormulaWindow.visible = false
                          qrCodeFormulaWindow.visible = false
                          jm_ProcessWindow.visible = false
                          io_MonitorWindow.visible = false
                          printerSettingWindow.visible = false
                          managerSettingWindow.visible = false
                          advanceSettingWindow.visible = false
                          servoParameterSetting.visible = false
                          materialRackParameter.visible = false
                          locationCompensateSetting.visible = false
                          anyLocationCompensate.visible = false
                          changePasswdWindow.visible = false
                          deviceLayoutWindow.visible = false

                          // 切换工作模式 - 手动加工
                          Cpp_Connect.write_modbus_rtu_Hold("48","3")
                      }
                      else if( currentPage === 5 )
                      {
                          loginWindow.visible = false
                          processWindow.visible = false
                          ls_LocationWindow.visible = false
                          lg_ChooseWindow.visible = false
                          extraLongProcessWindow.visible = false
                          extraShortProcessWindow.visible = false
                          pl_ProcessWindow.visible = false
                          netWorkFormulaWindow.visible = false
                          qrCodeFormulaWindow.visible = false
                          jm_ProcessWindow.visible = true
                          io_MonitorWindow.visible = false
                          printerSettingWindow.visible = false
                          managerSettingWindow.visible = false
                          advanceSettingWindow.visible = false
                          servoParameterSetting.visible = false
                          materialRackParameter.visible = false
                          locationCompensateSetting.visible = false
                          anyLocationCompensate.visible = false
                          changePasswdWindow.visible = false
                          deviceLayoutWindow.visible = false

                          // 切换工作模式 - 手动加工
                          Cpp_Connect.write_modbus_rtu_Hold("48","2")

                      }
                      else if( currentPage === 6 )
                      {
                          loginWindow.visible = false
                          processWindow.visible = false
                          ls_LocationWindow.visible = false
                          lg_ChooseWindow.visible = false
                          extraLongProcessWindow.visible = false
                          extraShortProcessWindow.visible = false
                          pl_ProcessWindow.visible = false
                          netWorkFormulaWindow.visible = false
                          qrCodeFormulaWindow.visible = false
                          jm_ProcessWindow.visible = false
                          io_MonitorWindow.visible = false
                          printerSettingWindow.visible = false
                          managerSettingWindow.visible = true
                          advanceSettingWindow.visible = false
                          servoParameterSetting.visible = false
                          materialRackParameter.visible = false
                          locationCompensateSetting.visible = false
                          anyLocationCompensate.visible = false
                          changePasswdWindow.visible = false
                          deviceLayoutWindow.visible = false
                          // 切换工作模式 - 手动加工
                          Cpp_Connect.write_modbus_rtu_Hold("48","8")
                      }
                  }
              }
           }
       }
    }
}
